import Vue from 'vue'
import VueRouter from 'vue-router'
import Menu from "../views/Menu";
import Main from "../views/Main";
import DataTotal from "../components/DataTotal";
import OrderList from "../views/OrderList";
import EmpList from "../views/EmpList";
import BusList from "../views/BusList";
import Setting from "../views/Setting";
import EmpLock from "../views/EmpLock";
import VipList from "../views/VipList";
import OrderExcel from "../views/OrderExcel";
import SellerPage from "../views/SellerPage";
import TrendPage from "../views/TrendPage";
import MapPage from "../views/MapPage";
import RankPage from "../views/RankPage";
import HotPage from "../views/HotPage";
import StockPage from "../views/StockPage";
import ScreenPage from "../views/ScreenPage";
import TopTotal from "../components/TopTotal";
import ReadMe from "../views/ReadMe";
import WS from "../components/WS";
import LoginPage from "../views/LoginPage";

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Index',
    redirect: '/menu/main'
  },
  {
    path: '/menu',
    name: 'Menu',
    //懒加载
    component: () => import('../views/Menu.vue'),
    children:[
      {path:'/menu/main',component:Main,meta: { title: '首页' }},
      {path:'/menu/data',component:DataTotal,meta: { title: '数据统计' }},
      {path:'/menu/order',component:OrderList,meta: { title: '订单管理' }},
      {path:'/menu/order/excel',component:OrderExcel,meta: { title: 'Excel管理' }},
      {path:'/menu/vip',component:VipList,meta: { title: '会员管理' }},
      {path:'/menu/emp',component:EmpList,meta: { title: '员工管理' }},
      {path:'/menu/car',component:BusList,meta: { title: '车辆管理' }},
      {path:'/menu/lock',component:EmpLock,meta: { title: '权限管理' }},
      {path:'/menu/setting',component:Setting,meta: { title: '系统设置' }},
      {path:'/menu/read',component:ReadMe,meta: { title: '文档' }},
    ],
    meta: { title: '主页' }
  },
  {
    path: '/sellerpage',
    name: 'SellerPage',
    component:SellerPage,
  },
  {
    path: '/trendpage',
    name: 'TrendPage',
    component:TrendPage
  },
  {
    path: '/mappage',
    name: 'MapPage',
    component:MapPage
  },
  {
    path: '/rankpage',
    name: 'RankPage',
    component:RankPage
  },
  {
    path: '/hotpage',
    name: 'HotPage',
    component:HotPage
  },
  {
    path: '/stockpage',
    name: 'StockPage',
    component:StockPage
  },
  {
    path: '/screenpage',
    name: 'ScreenPage',
    component:ScreenPage,
    meta: { title: '实时监控' }
  },
  {
    path: '/toptotal',
    name: 'TopTotal',
    component:TopTotal
  },
  {
    path: '/test',
    name: 'websocket',
    component:WS
  },
  {
    path: '/login',
    name: 'LoginPage',
    component: LoginPage,
  },
]

const router = new VueRouter({
  /* 解决不能通过地址栏url访问的错误  */
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})



// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
export default router
